
// state
export const state = () => ({
    userdata: null,
    datalist:[],
    token:'',
    datalist1:[],
})


// mutations
export const mutations = {

    setuserdata(state, data) {
        state.userdata = data
    },

    settoken(state, data) {
        state.token = data
    },

    setdatalist(state,data){
        state.datalist=data
    },

    setdatalist1(state,data){
        state.datalist1=data
    },

}

// actions 主要处理异步的数据
export const actions = {
    // 这是cookie的勾子函数,在页面强制刷新时触发,context 是上下文
    nuxtServerInit(store, context) {
        let token = context.app.$cookies.get("token") || ""
        store.commit("settoken", token)
    }
}

// getters 类似于计算属性
export const getters = {
    getNav(state) {
        return state.bNav ? '显示' : '隐藏'
    }
}